<%@ tag body-content="empty" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="format" tagdir="/WEB-INF/tags/shared/format"%>
<%@ taglib prefix="mproduct" tagdir="/WEB-INF/tags/mobile/product"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="ycommerce" uri="/WEB-INF/tld/ycommercetags.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ attribute name="product" required="true" type="de.hybris.platform.commercefacades.product.data.ProductData"%>

<h2 class="productHeadline" data-dialogheader="${product.name}">
	<div class="productTitle">${product.name}</div>
	<br/>
	<mproduct:productAverageReviewDetailPage product="${product}"/>
</h2>
<form id="addToCartForm" class="add_to_cart_form" action="<c:url value="/cart/add"/>" method="post">
	<div class='ui-grid-a accmob-quickviewItemInfo'>
		<div class='ui-block-a'>
			<a href="#" class="referencedProductImage" data-url="${productQuickViewUrl}" data-rel="dialog" data-transition="pop">
				<mproduct:productPrimaryImage product="${productReference.target}" format="thumbnail" zoomable='false'/>
			</a>
		</div>
		<div class='ui-block-b'>
			<a href='<c:url value="${product.url}"/>'> <spring:theme code="product.product.details.more"/></a>
			<%-- promotions --%>
			<div class="itemPromotionBox itemPromotionBoxSmall" data-theme="b">
				<ycommerce:testId code="productDetails_promotion_label">
					<c:if test="${not empty product.potentialPromotions}">
						<c:choose>
							<c:when test="${not empty product.potentialPromotions[0].couldFireMessages}">
								<p>${product.potentialPromotions[0].couldFireMessages[0]}</p>
							</c:when>
							<c:otherwise>
								<p>${product.potentialPromotions[0].description}</p>
							</c:otherwise>
						</c:choose>
					</c:if>
				</ycommerce:testId>
			</div>
			<span class="accmob-quickviewItemPrice"><format:price priceData="${product.price}"/></span>
		</div>
	</div>
	<div class='ui-grid-a accmob-quickviewItemQA'>
		<div class='ui-block-a'>
			<div class="prod_add_to_cart_quantity">
				<c:if test="${(product.purchasable) and (product.stockLevel gt 0)}">
					<select id="qty" class='qty' name="qty" data-theme="d">
						<option value="1"><spring:theme code="basket.page.quantity"/></option>
						<c:choose>
							<c:when test="${product.stockLevel le 100}">
								<c:set var="maxQuantity" value="${product.stockLevel}"/>
							</c:when>
							<c:otherwise>
								<c:set var="maxQuantity" value="100"/>
							</c:otherwise>
						</c:choose>
						<c:forEach var="i" begin="1" end="${maxQuantity}">
							<option value="${i}">${i}</option>
						</c:forEach>
					</select>
				</c:if>
				<input type="hidden" name="productCodePost" value="${product.code}"/>
			</div>
		</div>
		<div class="ui-block-b">
			<div class="accmob-quickviewItemAvailability">${product.stockLevel} &nbsp; <spring:theme code="product.variants.in.stock"/></div>
		</div>
	</div>
	<div id='addToBasket'>
		<c:set var="buttonType">button</c:set>
		<c:if test="${product.stockLevel gt 0 }">
			<c:set var="buttonType">submit</c:set>
			<spring:theme code="text.addToCart" var="addToCartText"/>
			<button type="${buttonType}"
					data-rel="dialog"
					data-transition="pop"
					data-theme="b"
					class="positive large <c:if test="${fn:contains(buttonType, 'button')}">out-of-stock</c:if>">
				<spring:theme code="text.addToCart" var="addToCartText"/>
				<spring:theme code="basket.add.to.basket"/>
			</button>
		</c:if>
	</div>
	</div>
</form>
